set more off

use "reassessments", clear

merge m:m swis_code year using "switchers"


replace reass = reass*100

keep if _m == 3

drop _m

keep if year > 1986 & year < 2012


egen nyearspost = count(year) if D == 1 & !mi(Dyr), by(swis_code)
egen nyearspre = count(year) if D == 0 & !mi(Dyr), by(swis_code)
egen nyearspostm = mean(nyearspost), by(swis_code)
egen nyearsprem = mean(nyearspre), by(swis_code)
replace nyearspost = nyearspostm
replace nyearspre = nyearsprem
drop nyearspostm nyearsprem
list  year D nyearspre nyearspost if swis== 12400

tab year

keep if mi(Dyr_ub)

gen D_5 = year - Dyr == -5
gen D_4 = year - Dyr == -4
gen D_3 = year - Dyr == -3
gen D_2 = year - Dyr == -2
gen D_1 = year - Dyr == -1
gen D0 = year - Dyr == 0
gen D1 = year - Dyr == 1
gen D2 = year - Dyr == 2
gen D3 = year - Dyr == 3
gen D4 = year - Dyr == 4
gen D5 = year - Dyr == 5
gen D6 = year - Dyr == 6
gen D7 = year - Dyr == 7
gen D8 = year - Dyr == 8
gen D9 = year - Dyr == 9
gen D10 = year - Dyr >= 10
replace D10 = 0 if mi(Dyr) // important

parmby "xi: areg reass D_5 D_4 D_3 D_2 D_1 D0 D1 D2 D3 D4 D5 D6 D7 D8 D9 D10 i.year, a(swis) cl(swis)", fast

keep if parmseq <= 16
replace parmseq = parmseq - 6


#delimit;

gr tw
	(line min max parmseq, lcol(black black) lpat(shortdash shortdash))
	(line est parmseq, lpat(solid) lcol(black) lwid(thick))
	(scatteri 0 -5 0 10, c(l) m(i) col(black) lpat(solid) lwid(thin))
	(scatteri -10.5 0 30 0, c(l) m(i) col(black) lpat(solid) lwid(thin))
	,
		xlab(-5(1)10)
		plotregion(style(none))
		legend(off)
		ylab(, angle(horizontal) format(%10.0f))
		l2title("Difference in reassessments")
		xtitle("Years since switch to appointed assessor")
		text(31.5 -.1 "Before appointed", placement(left))
		text(31.5 .1 "After appointed", placement(right))
		ytitle("")
		;
		
#delimit cr
 
gr export "figure A1.eps", replace
